-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create the toolkit for plugin authors #88
Conversation
@daniilsapa could you review this please? |
Great job!
I really don't have any suggestions or complaints about it. I think it's good to go. 👍 Should we open an issue to create a short guide on how to build plugins for Steiger, so we remember that this task is still on the plate? Also, we could open an issue to cover the toolkit with tests as you mentioned that was a whole separate story. |
Yep, I opened an issue for type tests already (#98), and I will also create an issue for the guide. I still don't fully know where is best to host these guides. For 1.0.0, we will definitely want a dedicated docs website, but for now we might use GitHub wiki. |
I'll let you merge your PR first and then take care of the conflicts and merge this one after |
treeshake: true, | ||
clean: true, | ||
esbuildOptions(options) { | ||
options.define = { 'import.meta.vitest': 'undefined' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, I've been meaning to ask you for a while. Why do some functions have tests for them placed in the same file? Why can't we just put them in separate files and remove that redundancy of having to replace import.meta.vitest
with undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just find it more convenient sometimes, especially when there's not a lot of code and not a lot of test cases. Having a separate *.spec.ts
gets in the way of the file structure, so if I have a couple files, the duplicated names of test files are a bit annoying to deal with.
Okay, I merged the updates and cleaned everything up. Also tested it with the test cases from #71. @daniilsapa could you give it a final review please? |
@@ -65,7 +65,3 @@ export const linter = { | |||
return [runRulesFx.doneData, () => watcher.close()] as const | |||
}, | |||
} | |||
|
|||
export function defineConfig(config: Config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great updates!
I have only one question about this thing.
Could you please explain why you decided to remove this function? I know it just returned the same object you passed it. This would cause errors like "The requested module does not provide an export named 'defineConfig'" and could be annoying for the users. And I know that the project is in the beta stage, so they should expect some APIs to change.
But in the future, it might happen that we need to do some pre-processing on the config. In fact, I was thinking the opposite, about adding some flag like "defined" for the config that went through defineConfig
and considering it the only valid config. Yeah, and throw an exception if it doesn't have the flag, so people get used to wrapping their configs in defineConfig
for the sake of some far-off new but quite possible features added to defineConfig
.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think that I removed it by mistake, thanks for bringing that up. I wanted to beef up the type inference capabilities of this function, but gave up for the moment, and then just accidentally removed the whole thing.
But in the future, it might happen that we need to do some pre-processing on the config.
Nah, I would really prefer the defineConfig
function to just be for typing. That seems to be the convention with other tools in the JS ecosystem, no one expects this function to be a requirement or to modify the config in any way. Besides, any processing we could do through this function could also be done in Steiger itself, without putting any burden on the user
I'll bring this function back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any issues now. Thanks!
Closes #71
This is a significant refactoring to the types and locations of utilities. Few things to note:
@steiger/toolkit
. It has these exports:Issues to fix:
Fixing it is beyond my power right now, I would like to at least get the baseline down. We don't use context currently, so once we start using it, then we can improve on this.